package com.yyy.config;

import com.yyy.example.ConsumerService;
import com.yyy.modules.DefaultMsgCallbackHandler;
import com.yyy.modules.MsgTemplate;
import com.yyy.modules.core.MsgDispatcherService;
import com.yyy.modules.core.MsgFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author yyy
 * @Date 2020-10-18 13:01
 * @Email yangyouyuhd@163.com
 */
@Configuration
public class MsgAutoConfiguration {

    @Bean
    @Autowired
    public MsgTemplate msgTemplate(MsgDispatcherService msgDispatcherService) {
        System.out.println("MsgTemplate完成初始化");
        return new MsgTemplate(msgDispatcherService);
    }

    @Bean
    public MsgFactory msgFactory() {
        System.out.println("MsgFactory完成初始化");
        return new MsgFactory();
    }

    @Bean
    @Autowired
    public MsgDispatcherService msgDispatcherService(MsgFactory msgFactory) {
        return new MsgDispatcherService(msgFactory);
    }

    @Bean
    public DefaultMsgCallbackHandler defaultMsgCallbackHandler(){
        return new DefaultMsgCallbackHandler();
    }
}
